﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using QuizEngine.Data;

namespace QuizEngine.Presentation
{
    public partial class QuestionControl : UserControl
    {
        public QuestionControl(List<Question> questions)
        {
            InitializeComponent();
            this.SuspendLayout();
            this.Dock = DockStyle.Fill;
            foreach (Question question in questions)
            {
                FlowLayoutPanel questionFlowPanel = new FlowLayoutPanel();
                questionFlowPanel.AutoSize = true;
                questionFlowPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                questionFlowPanel.Dock = DockStyle.Top;
                questionFlowPanel.FlowDirection = FlowDirection.TopDown;
                questionFlowPanel.WrapContents = false;
                questionFlowPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
                this.Controls.Add(questionFlowPanel);
                Label questionContentLbl = new Label();
                questionContentLbl.Text = question.Content;
                questionFlowPanel.Controls.Add(questionContentLbl);
                if (question.QuestionType == 1)
                {
                    foreach (Choice choice in question.Choices)
                    {
                        RadioButton choiceRb = new RadioButton();
                        choiceRb.Text = choice.Content;
                        questionFlowPanel.Controls.Add(choiceRb);
                    }
                }
                else
                {
                    foreach (Choice choice in question.Choices)
                    {
                        CheckBox choiceChk = new CheckBox();
                        choiceChk.Text = choice.Content;
                        questionFlowPanel.Controls.Add(choiceChk);
                    }
                }
            }
            this.ResumeLayout();
        }
    }
}
